package com.ktgj.file.api.factory;

import com.ktgj.common.core.domain.R;
import com.ktgj.file.api.RemoteFilesService;
import com.ktgj.file.api.domain.SysFileApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.Map;

@Component
public class RemoteFilesFallbackFactory implements FallbackFactory<RemoteFilesService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteFilesFallbackFactory.class);

    @Override
    public RemoteFilesService create(Throwable cause) {
        log.error("文件服务调用失败:{}", cause.getMessage());
        return new RemoteFilesService() {
            @Override
            public String airlineLogo() {
                return null;
            }

            public R<SysFileApi> upload(@RequestPart(value = "file") MultipartFile file)
            {
                return null;
            }

            @Override
            public File document(MultipartFile file) {
                log.error("上传文件到服务器失败:{}", cause.getMessage());
                return null;
            }
        };
    }


}
